package reflect;

import java.util.Scanner;

public class ReflectDemo2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个类名:");
        String className = sc.nextLine();
        try {
            Class cs = Class.forName(className);

            Object obj = cs.newInstance();
            System.out.println(obj);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }
    }
}
